//import axios from 'axios';
import axios from '../utils/http';

export const userLogin = params => { return axios.post(`users/login`, params).then(res => res.data); };

export const getUserInfo = params => { return axios.get(`users`).then(res => res.data); };

export const getPermissions = params => { return axios.get(`users/permissions`).then(res => res.data); };

export const getDevices = params => { return axios.get(`devices`).then(res => res.data); };

export const getPositions = params => { return axios.get(`positions`).then(res => res.data); };

export const getEvents = params => { return axios.get(`events`,{params:params}).then(res => res.data); };

export const getHistorys = params => { return axios.get(`positions/history`,{params:params}).then(res => res.data); };

export const readEvent = id => { return axios.get(`events/`+id).then(res => res.data); };

export const deleteEvent = id => { return axios.delete(`events/`+id).then(res => res.data); };

export const addDevice = params => { return axios.post(`devices`, params).then(res => res.data); };

export const updateDevice = params => { return axios.put(`devices/`+params.id, params).then(res => res.data); };

export const getDeviceTypes = params => { return axios.get(`devicetypes`).then(res => res.data); };

export const deleteDevice = id => { return axios.delete(`devices/`+id).then(res => res.data); };

export const register = params => { return axios.post(`users/register`, params).then(res => res.data); };

export const getGeofences = params => { return axios.get(`geofences`).then(res => res.data); };

export const getConfigMaps = params => { return axios.get(`config/maps`).then(res => res.data); };

export const getCommandViews = params => { return axios.get(`command/views`).then(res => res.data); };

//发送命令
export const sendCommand = params => { return axios.post(`command/send`,params).then(res => res.data); };

//修改密码
export const updatePass = params => { return axios.put(`users/updatepass`,params).then(res => res.data); };
